//
//  XLCommitSetSirView.m
//  XiangLove
//
//  Created by 宋振 on 2018/8/23.
//  Copyright © 2018年 BAOMIHUA.COM. All rights reserved.
//

#import "XLCommitSetSirView.h"

#import "XLPersonCenterTool.h"

@interface XLCommitSetSirView ()



@end

@implementation XLCommitSetSirView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = RGBA(255, 255, 255, 1);
        self.layer.cornerRadius = 12;
        self.layer.masksToBounds = YES;
        
        /**
         显示UI
         */
        [self customeView];
        
    }
    
    return self;
}

/**
 设置界面显示UI
 */
- (void)customeView
{
    /**
     提示
     */
    UILabel *titleLbl = [[UILabel alloc] init];
    
    titleLbl.attributedText = [[NSAttributedString alloc] initWithString:@"已为您自动生成资料" attributes:@{
                                                                                                NSKernAttributeName:@1,
                                                                                                NSForegroundColorAttributeName:RGB(17, 17, 17),
                                                                                                NSFontAttributeName:[UIFont fontWithName:@"PingFangSC-Regular" size:17]
                                                                                                }];
    titleLbl.textAlignment = NSTextAlignmentCenter;
    
    [self addSubview:titleLbl];
    
    [titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(11);
        make.centerX.equalTo(self.mas_centerX);
        make.height.mas_equalTo(24);
    }];
    
    /**
     头像设置
     */
    UIView *avatarBg = [[UIView alloc] init];
    [self addSubview:avatarBg];
    avatarBg.layer.cornerRadius = 36;
    avatarBg.layer.masksToBounds = YES;
    avatarBg.backgroundColor = RGB(255, 187, 1);
    [avatarBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLbl.mas_bottom).offset(27);
        make.centerX.equalTo(self.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(72, 72));
    }];
    
    
    self.avatarView = [[UIImageView alloc] init];
    [avatarBg addSubview:self.avatarView];
    self.avatarView.layer.cornerRadius = 35;
    self.avatarView.layer.masksToBounds = YES;
    
    [self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(avatarBg).insets(UIEdgeInsetsMake(1, 1, 1, 1));
    }];
    
    //标志
    UIImageView *arrowImg = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"popup_icon_boy_n"] imageWithRenderingMode:(UIImageRenderingModeAlwaysOriginal)]];
    [self addSubview:arrowImg];
    
    [arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(avatarBg.mas_bottom);
        make.centerX.equalTo(self.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(8, 9));
    }];
    
    //昵称
    self.nickName = [[UILabel alloc] init];
    self.nickName.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.nickName];
    
    [self.nickName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(avatarBg.mas_bottom).offset(17);
        make.centerX.equalTo(self.mas_centerX);
        make.height.mas_equalTo(15);
    }];
    
    //分割线
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = RGB(204, 204, 204);
    [self addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nickName.mas_bottom).offset(12);
        make.centerX.equalTo(self.mas_centerX);
        make.width.mas_equalTo(1);
        make.height.mas_equalTo(15);
    }];
    
    //性别
    self.genderLbl = [[UILabel alloc] init];
    self.genderLbl.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.genderLbl];
    
    [self.genderLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(lineView.mas_left).offset(-12);
        make.top.equalTo(lineView.mas_top);
        make.height.mas_equalTo(15);
    }];
    
    //年龄
    self.ageLbl = [[UILabel alloc] init];
    self.ageLbl.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.ageLbl];
    
    [self.ageLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lineView.mas_right).offset(12);
        make.top.equalTo(lineView.mas_top);
        make.height.mas_equalTo(15);
    }];
    
    //删除按钮
    self.deleteButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.deleteButton.frame = CGRectMake(0, 0, kScale(24), kScale(24));
    [self.deleteButton setImage:[UIImage imageNamed:@"pop_icon_cha"] forState:(UIControlStateNormal)];
//    [self.deleteButton addTarget:self action:@selector(deleteNewUserBag:) forControlEvents:(UIControlEventTouchUpInside)];
    [self addSubview:self.deleteButton];
    
    [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(5);
        make.right.equalTo(self.mas_right).offset(-5);
        make.width.height.mas_equalTo(kScale(24));
    }];
    
    //完成按钮
    self.saveSucessBt = [[UIButton alloc] init];
    
    self.saveSucessBt.layer.cornerRadius = 5;
    self.saveSucessBt.layer.masksToBounds = YES;
    [self.saveSucessBt setTitle:@"修改设置" forState:(UIControlStateNormal)];
    [self.saveSucessBt setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    self.saveSucessBt.backgroundColor = RGB(255, 187, 1);
    [self addSubview:self.saveSucessBt];
    
    [self.saveSucessBt mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(240, 40));
        make.centerX.equalTo(self.mas_centerX);
        make.bottom.equalTo(self.mas_bottom).offset(-14);
    }];
}

// Tools
- (NSAttributedString *)setNickNameAttributeWithString:(NSString *)nickName
{
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:nickName attributes:@{
                                                                                                     NSKernAttributeName:@1,
                                                                                                     NSForegroundColorAttributeName:RGB(17, 17, 17),
                                                                                                     NSFontAttributeName:[UIFont fontWithName:kFontNamePFRegular size:15]
                                                                                                     }];
    
    return attribute;
}

- (NSAttributedString *)setGenderString:(NSString *)gender
{
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"性别：%@",gender] attributes:@{
                                                                                                     NSKernAttributeName:@1,
                                                                                                     NSForegroundColorAttributeName:RGB(102, 102, 102),
                                                                                                     NSFontAttributeName:[UIFont fontWithName:kFontNamePFRegular size:15]
                                                                                                     }];
    
    return attribute;
}

- (NSAttributedString *)setAgeString:(NSString *)age
{
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"性别：%@",age] attributes:@{
                                                                                                                                        NSKernAttributeName:@1,
                                                                                                                                        NSForegroundColorAttributeName:RGB(102, 102, 102),
                                                                                                                                        NSFontAttributeName:[UIFont fontWithName:kFontNamePFRegular size:15]
                                                                                                                                        }];
    
    return attribute;
}

@end
